import Cookies from 'js-cookie'

const TokenKey = '_Admin-Token'
const AuthsKey = '_Admin-Auths'
const UserKey = '_Admin-User'

export function getToken() {
  return Cookies.get(TokenKey)
}

export function setToken(token) {
  return Cookies.set(TokenKey, token)
}

export function removeToken() {
  return Cookies.remove(TokenKey)
}

export function getAuths() {
  return JSON.parse(Cookies.get(AuthsKey) || '[]')
}

export function setAuths(auths) {
  return JSON.stringify(Cookies.set(AuthsKey, auths))
}

export function removeAuths() {
  return Cookies.remove(AuthsKey)
}

export function getUser() {
  return JSON.parse(Cookies.get(UserKey) || '{}')
}

export function setUser(user) {
  return JSON.stringify(Cookies.set(UserKey, user))
}

export function removeUser() {
  return Cookies.remove(UserKey)
}

